#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;
using tl = tuple < int, int, int >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e6 + 10;
int a[N], n, b[N], lst, f[N][2][2], cta, ctb;
char ans[N];
inline void upd(int &x, const int &y) { x = x > y ? x : y; }

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in;
	rep(i, 1, n << 1) a[i] = in;
	rep(i, 1, n << 1) b[i] = in;
	f[1][0][0] = f[1][1][1] = 1;
	rep(i, 2, n << 1) {
		if(a[i] >= a[i - 1]) upd(f[i][0][0], f[i - 1][0][0] + 1), upd(f[i][0][1], f[i - 1][0][1]);
		if(a[i] >= b[i - 1]) upd(f[i][0][0], f[i - 1][1][0] + 1), upd(f[i][0][1], f[i - 1][1][1]);
		if(b[i] >= a[i - 1]) upd(f[i][1][0], f[i - 1][0][0]), upd(f[i][1][1], f[i - 1][0][1] + 1);
		if(b[i] >= b[i - 1]) upd(f[i][1][0], f[i - 1][1][0]), upd(f[i][1][1], f[i - 1][1][1] + 1);
	}
	lst = 2e9;
	per(i, n << 1, 1) {
		if(a[i] <= lst && cta + f[i][0][0] >= n && ctb + f[i][0][1] >= n) lst = a[i], cta++, ans[i] = 'A';
		else if(b[i] <= lst && cta + f[i][1][0] >= n && ctb + f[i][1][1] >= n) lst = b[i], ctb++, ans[i] = 'B';
		else return puts("-1"), 0;
	}
	printf("%s\n", ans + 1); return 0;
}
